/**
 * sysInterfaceMessageServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:第三方通道设置管理
 * 
 * 历史版本:2017-03-27 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.sys.sysInterfaceMessage.service.impl;

import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.common.util.SqlUtil;
import com.fmjr.sys.sysInterfaceMessage.bean.SysInterfaceMessage;
import com.fmjr.sys.sysInterfaceMessage.dao.SysInterfaceMessageDao;
import com.fmjr.sys.sysInterfaceMessage.service.ISysInterfaceMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("sysInterfaceMessageService")
public class  SysInterfaceMessageServiceImpl implements ISysInterfaceMessageService {
	

	@Autowired
    private SysInterfaceMessageDao sysInterfaceMessageDao;

	/**
	 * 根据条件查询第三方通道设置记录
	 * @author lunli
	 * @param  pager
	 * @return SysInterfaceMessageList
	 * @throws BusinessException
	 */
	public void selectSysInterfaceMessageList(Pager<SysInterfaceMessage> pager) throws BusinessException{
		int totalCount = sysInterfaceMessageDao.selectSysInterfaceMessageCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<SysInterfaceMessage> list = sysInterfaceMessageDao.selectSysInterfaceMessageList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询第三方通道设置记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public SysInterfaceMessage selectSysInterfaceMessageById(Long id) throws BusinessException{
		return sysInterfaceMessageDao.selectSysInterfaceMessageById(id);
	}

	/**
	 *  删除第三方通道设置记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteSysInterfaceMessageById(Long id) throws BusinessException{
		return sysInterfaceMessageDao.deleteSysInterfaceMessageById(id);
	}
	
	/**
	 * 修改第三方通道设置记录
	 * @author lunli
	 * @param sysInterfaceMessage
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateSysInterfaceMessage(SysInterfaceMessage sysInterfaceMessage) throws BusinessException{
		//sysInterfaceMessage.setUpdateDate(new Date());
		return sysInterfaceMessageDao.updateSysInterfaceMessageSelective(sysInterfaceMessage);
	}

	/**
	 * 新增第三方通道设置记录
	 * @author lunli
	 * @param sysInterfaceMessage
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createSysInterfaceMessage(SysInterfaceMessage sysInterfaceMessage) throws BusinessException{
//		sysInterfaceMessage.setCreateDate(new Date());
		return sysInterfaceMessageDao.createSysInterfaceMessage(sysInterfaceMessage);
	}

	@Override
	public List<SysInterfaceMessage> selectSysInterfaceMessageList() throws BusinessException {
		List<SysInterfaceMessage> list = sysInterfaceMessageDao.selectSysInterfaceMessageAll();
		return list;
	}
	

	

}
